package com.epro.dx.widget;

import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;

public class DataYearOrMonthPickerDialog extends DatePickerDialog {
	private String dataStr;
	public DataYearOrMonthPickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth,String dataStr) {  
        super(context, callBack, year, monthOfYear, dayOfMonth);  
//        this.setTitle(year + "年" + (monthOfYear + 1) + "月");
        this.dataStr=dataStr;
        this.setTitle("Please choose "+dataStr);
       
    }  
  
    @Override  
    public void onDateChanged(DatePicker view, int year, int month, int day) {  
        super.onDateChanged(view, year, month, day);
        this.setTitle("Please choose "+dataStr);
    }  
    
    
    /**
     * 从当前Dialog中查找DatePicker子控件
     * 
     * @param group
     * @return
     */
    private DatePicker findDatePicker(ViewGroup group) {
        if (group != null) {
            for (int i = 0, j = group.getChildCount(); i < j; i++) {
                View child = group.getChildAt(i);
                if (child instanceof DatePicker) {
                    return (DatePicker) child;
                } else if (child instanceof ViewGroup) {
                    DatePicker result = findDatePicker((ViewGroup) child);
                    if (result != null)
                        return result;
                }
            }
        }
        return null;
    }
}
